package com.xatz.scanner

import android.app.Dialog
import android.content.Context
import android.view.animation.AnimationUtils
import com.xatz.scanner.databinding.DialogLoadingViewBinding

/**
 * author tdq
 * date 2021/06/10.
 * description：进度框
 */
class NetProgressDialog(context: Context) : Dialog(context) {
    private val binding = DialogLoadingViewBinding.inflate(layoutInflater)

    init {
        setContentView(binding.root)
        window?.setBackgroundDrawableResource(android.R.color.transparent)
    }

    fun setTextTip(tip: String) {
        binding.tvInfo.text = tip
    }

    /**
     * 展示对话框
     */
    fun showDialog() {
        val animation = AnimationUtils.loadAnimation(context, R.anim.anim_dialog_load)
        // 显示动画
        binding.ivProgress.startAnimation(animation)
        show()

    }

    /**
     * 取消对话框
     */
    fun closeDialog() {
        binding.ivProgress.clearAnimation()
        dismiss()
    }

}